package com.brogent.contacts;

import java.util.HashSet;

import android.app.Activity;
import android.database.Cursor;
import android.os.Bundle;
import android.provider.Contacts;
import android.provider.Contacts.People;
import android.text.TextUtils;
import android.util.Log;

public class MainActivity extends Activity {
    private final String TAG = this.getClass().getSimpleName();
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        String friendName = "A";
        HashSet<Long> bindedId = new HashSet<Long>();
        bindedId.add(new Long(10));
//        String where = "people." + People._ID + " NOT IN (" + TextUtils.join(",", bindedId) + ") AND " + People.DISPLAY_NAME
//        + " LIKE '%" + friendName + "%'";
        String where = People._ID + " = 1";
        Log.e(TAG, "people content uri" + People.CONTENT_URI.toString());

        Cursor cursor = MainActivity.this.getContentResolver().query(People.CONTENT_URI,
                new String[] { People._ID, People.DISPLAY_NAME }, where, null, " UPPER(" + People.DISPLAY_NAME + ") ASC ");
        for(int i = 0; i < cursor.getColumnCount(); i++) {
            Log.e(TAG, cursor.getColumnName(i));
        }
        if (cursor.moveToFirst()) {
            do {
                Log.e(TAG, "value = " + cursor.getString(cursor.getColumnIndex(People.DISPLAY_NAME)));
            } while(cursor.moveToNext() );
        }
    }
}